import { WeElement, define } from 'omi'

import './index.css'

define('order-type-picker', class extends WeElement{
  data={
    array: ["房间号", "包厢号", "桌号"],
    index: -1
  }

  install(){

  }

//选择预约订单类型
  bindPickerChange=(e)=>{
    console.log(e);
    if(this.data.array[e.detail.value] == '桌号'){
      wx.showToast({
        title: '该类型未开放...',
        icon: 'none'
      })
      return;
    }else{
      this.data.index = e.detail.value;
      this.fire('choosetype', {
        date: this.data.array[this.data.index]
      })
      this.update();
    }
  }

  render(){
    return(
      <view class="order_type_picker">
        <picker
          value={index}
          range={array}
          bindchange={bindPickerChange}
        >
          <view>
          {
              array[index] ? array[index]:'请选择您的订单类型 ' 
        }
          </view>
        </picker>
      </view>
    )
  }
})